home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / DTS.Lib / DTS.Lib.headers / Window2.h < prev   
Encoding:
C/C++ Source or Header  |  1994-06-11  |  50.1 KB  |  1,328 lines  |  [TEXT/KAHL]

  1. #ifndef __WINDOW2__
  2. #define __WINDOW2__
  3.  
  4. #ifndef __TYPES__
  5. #include <Types.h>
  6. #endif
  7.  
  8.  
  9.  
  10. OSErr            DoNewWindow(FileRecHndl frHndl, WindowPtr *retWindow,
  11.                             WindowPtr relatedWindow, WindowPtr behind);
  12.     /*
  13.     **    ¶ Create window for AppsToGo document.
  14.     **
  15.     **    INPUT:    frHndl            This file reference is used to create a window.  At this
  16.     **                            point there is (or should be) window creation information
  17.     **                            in the file reference.  If you are using the AppsToGo
  18.     **                            application editor to create your documents, then the
  19.     **                            information is in the file reference at this point.
  20.     **            relatedWindow    This window is what is used to determine which monitor
  21.     **                            the window should be created on.  If there is a related
  22.     **                            window passed in, DoNewWindow determines which monitor
  23.     **                            holds most of the window.  That monitor is then the
  24.     **                            target monitor for the new window.
  25.     **            behind            This window is the window that the new window is created
  26.     **                            behind.  Pass in -1 if the window is to be created as
  27.     **                            the frontmost window.  Pass in 0 if it is to be created
  28.     **                            as the backmost window.
  29.     **    OUTPUT:    retWindow        Return the created window here.  If you don’t care to
  30.     **                            know, then pass in nil.
  31.     **    RESULT:    OSErr            If an error is returned, then no window was created.
  32.     **
  33.     **    This function is called by the application or framework at appropriate times to
  34.     **    give a document a window.  To create a document window, first a document is created
  35.     **    by the application via NewDocument or OpenDocument.  If this succeeds then the
  36.     **    application needs to create a window for the document.  To do this, the application
  37.     **    calls DoNewWindow.  DoNewWindow calls the content initialization procedure, which
  38.     **    by default is InitContent.  If you want a different content initialization
  39.     **    procedure, replace the default procedure pointer initContentProc with your own.
  40.     **    Normally however, you will just place your own content initialization procedure in
  41.     **    the function InitContent.  It is possible though that your application has more
  42.     **    than one document type and window type.  If this is the case, then you may very
  43.     **    well want an alternate content initialization procedure.  If you do, you will want
  44.     **    to replace the default procedure pointer after the NewDocument or OpenDocument
  45.     **    call and before the call to DoNewWindow.  (You may place the code for replacing the
  46.     **    content initialization procedure and imaging procedure in the function InitDocument.
  47.     **    The defaults are already established at that point.  You would just replace them
  48.     **    with the alternates.
  49.     **
  50.     **    __________
  51.     **
  52.     **    Also see:    NewDocument, OpenDocument. */
  53.  
  54.  
  55. void            NewWindowTitle(WindowPtr window, StringPtr altTitle);
  56.     /*
  57.     **    ¶ Change the window/document title.
  58.     **
  59.     **    INPUT:    window
  60.     **            altTitle
  61.     **
  62.     **    Call this function if you want to change the title of the window.
  63.     **    If you pass in nil, the window title will be gotten from the FSSpec of the
  64.     **    document.  If you pass in an alternate title in altTitle, that will be used
  65.     **    instead of the document name. */
  66.  
  67.  
  68.  
  69. Boolean            DisposeAllWindows(void);
  70.     /*
  71.     **    ¶ Dispose the windows, giving user the chance to abort.
  72.     **
  73.     **    This function iterates through all of the windows and calls DisposeOneWindow
  74.     **    on each one.  If DisposeOneWindow returns that the user canceled the closing
  75.     **    of a window that needed saving, then DisposeAllWindows also aborts.  This
  76.     **    is used when an application is quitting. */
  77.  
  78.  
  79.  
  80. Boolean            DisposeOneWindow(WindowPtr window, short saveMode);
  81.     /*
  82.     **    ¶ Dispose one window, giving the user the chance to abort.
  83.     **
  84.     **    INPUT:    window
  85.     **            saveMode
  86.     **
  87.     **    This function does exactly as you would expect.  The saveMode indicates
  88.     **    whether the window is being closed due to a close request, or due to the
  89.     **    application being quit.  If true is returned, then disposing of the window
  90.     **    was successful.  If false is returned, the user may have canceled the close
  91.     **    due to the document needing to be saved, a dialog as such popping up, and
  92.     **    the user clicking cancel.
  93.     **
  94.     **    If the user says it is okay to dispose the window, DisposeOneWindow calls
  95.     **    the window’s FreeWindow and FreeDocument procedures to give the application
  96.     **    a chance to release application-specific memory associated with the window
  97.     **    and document.
  98.     **
  99.     **    __________
  100.     **
  101.     **    Also see:    DisposeAllWindows. */
  102.  
  103.  
  104. WindowPtr        SetFilePort(FileRecHndl frHndl);
  105.     /*
  106.     **    ¶ Given file, set the port to the document’s port.
  107.     **
  108.     **    INPUT:    frHndl
  109.     **
  110.     **    This function sets the current port for the designated file.  It also returns
  111.     **    the old port so that the port can be restored, if so desired.  Note that you
  112.     **    can always get the window for a document by simply dereferencing the doc handle
  113.     **    as follows:  window = (*frHndl)->fileState.window;
  114.     **    Keep in mind that a document doesn’t have to have a window.  If you created the
  115.     **    document yourself via NewDocument or OpenDocument, the document doesn’t have a
  116.     **    window assigned to it yet, and therefore the above dereference will return nil. */
  117.  
  118.  
  119.  
  120. void            DoResizeWindow(WindowPtr window, short oldh, short oldv);
  121.     /*
  122.     **    ¶ Called after a window is resized via grow or zoom.
  123.     **
  124.     **    INPUT:    window
  125.     **            oldh
  126.     **            oldv
  127.     **
  128.     **    This function is called when a window is resized.  This function may need
  129.     **    to know the old size of the window.  The new size is determined by the
  130.     **    dimensions of the window that was resized.  It moves and resizes the
  131.     **    document scrollbars and growIcon (if any) to reflect the new size of
  132.     **    the window.  It then calls the procedure stored in the procPtr field
  133.     **    resizeContentProc, in case there is additional sizing necessary for the window.
  134.     **    The default resizeContentProc is ResizeContent.  If you wish an alternate
  135.     **    resizeContentProc, then you can replace the default in the function
  136.     **    InitDocument, as the default is already established at this point. */
  137.  
  138.  
  139.  
  140. void            GetWindowChange(WindowPtr window, short oldh, short oldv, short *dx, short *dy);
  141.     /*
  142.     **    ¶ Given the old size, this returns the difference between the old size and the new size.
  143.     **
  144.     **    INPUT:    window
  145.     **            oldh
  146.     **            oldv
  147.     **    OUTPUT:    dx
  148.     **            dy
  149.     **
  150.     **    This function returns the difference between the old window size and the new window
  151.     **    size.  Pass in the old window size, and this function looks up the current size,
  152.     **    gets the difference, and returns it. */
  153.  
  154.  
  155.  
  156. void            DoUpdateSeparate(WindowPtr window, RgnHandle *contRgn, RgnHandle *frameRgn);
  157.     /*
  158.     **    ¶ Separates the updateRgn into a frameRgn and a contentRgn.
  159.     **
  160.     **    INPUT:    window
  161.     **    OUTPUT:    contRgn
  162.     **            frameRgn
  163.     **
  164.     **    This function separates the update region into two portions.  One portion is
  165.     **    the frame area, which consists of document scrollbars and growIcon (if any), plus
  166.     **    an optional application-defined frame area.  The other portion is the rest of the
  167.     **    window content that needs updating.  This separation is so that the document
  168.     **    scrollbars can be updated first, and then this area can be clipped out of the rest
  169.     **    of the updating so that the window content doesn’t draw over the document
  170.     **    scrollbars and growIcon.  The clipping is managed with just the visRgn.  This frees
  171.     **    up the clipRgn for application specific clipping.  Note that if either region
  172.     **    is computed to be empty, DoUpdateSeparate will return a nil for that handle.
  173.     **
  174.     **    __________
  175.     **
  176.     **    Also see:    BeginContent, EndContent, BeginFrame, EndFrame, DoCalcScrollRgn, DoCalcFrameRgn. */
  177.  
  178.  
  179.  
  180. void            BeginContent(WindowPtr window);
  181.     /*
  182.     **    ¶ Used instead of BeginUpdate to draw to just the content area.
  183.     **
  184.     **    INPUT:    window
  185.     **
  186.     **    This function clips out the document scrollbars and growIcon from the updatable
  187.     **    area.  It also sets the origin of the port to the current document scrollbar
  188.     **    values.  BeginContent must be balanced by a call to EndContent.  BeginContent calls
  189.     **    BeginUpdate, and BeginUpdate calls can’t be nested.  Due to this, BeginContent has
  190.     **    a usage counter, which prevents nested calls to BeginUpdate.  BeginContent clips
  191.     **    out the document scrollbar and growIcon area without involving the clipRgn so that
  192.     **    the application is free to use the clipRgn as it sees fit.  The only caveat is that
  193.     **    you can not modify the updateRgn between the BeginContent and EndContent calls, as
  194.     **    anything contributed to the updateRgn between these calls will be lost.  If you
  195.     **    need to do this, accumulate the areas in a separate region, call EndContent, and
  196.     **    then call InvalRgn.
  197.     **
  198.     **    __________
  199.     **
  200.     **    Also see:    BeginFrame, EndFrame, DoCalcScrollRgn, DoCalcFrameRgn, DoUpdateSeparate. */
  201.  
  202.  
  203. void            EndContent(WindowPtr window);
  204.     /*
  205.     **    ¶ Used instead of EndUpdate to balance BeginContent calls.
  206.     **
  207.     **    INPUT:    window
  208.     **
  209.     **    Calls to BeginContent must be balanced.  They also don’t nest.  EndContent undoes
  210.     **    the clipping of the frame area that BeginContent invoked.
  211.     **
  212.     **    __________
  213.     **
  214.     **    Also see:    BeginFrame, EndFrame, DoCalcScrollRgn, DoCalcFrameRgn, DoUpdateSeparate. */
  215.  
  216.  
  217.  
  218. void            BeginFrame(WindowPtr window);
  219.     /*
  220.     **    ¶ Used instead of BeginUpdate to draw to just the frame area.
  221.     **
  222.     **    INPUT:    window
  223.     **
  224.     **    This function does the same thing as BeginContent, except that it clips out everything
  225.     **    except the frame area.  The frame area consists of the sidebars and any additional
  226.     **    application-defined frame area.  The application-defined frame area is defined in the
  227.     **    AppWannabe function CalcFrameArea.  Also, the origin is set to -16384,0, which is the
  228.     **    coordinate space for sidebar controls created with the AppsToGo application editor.
  229.     **    Calls to BeginFrame must be balanced with calls to EndFrame.
  230.     **
  231.     **    __________
  232.     **
  233.     **    Also see:    BeginContent, EndContent, DoCalcScrollRgn, DoCalcFrameRgn, DoUpdateSeparate. */
  234.  
  235.  
  236.  
  237. void            EndFrame(WindowPtr window);
  238.     /*
  239.     **    ¶ Used instead of EndUpdate to balance BeginFrame calls.
  240.     **
  241.     **    INPUT:    window
  242.     **
  243.     **    Calls to BeginFrame must be balanced.  They also don’t nest.  EndFrame undoes the
  244.     **    clipping of the frame area that BeginFrame invoked.
  245.     **
  246.     **    __________
  247.     **
  248.     **    Also see:    BeginContent, EndContent, DoCalcScrollRgn, DoCalcFrameRgn, DoUpdateSeparate. */
  249.  
  250.  
  251.  
  252. void            AdjustScrollBars(WindowPtr window);
  253.     /*
  254.     **    ¶ Modify scrollbar values to reflect other window changes.
  255.     **
  256.     **    INPUT:    window
  257.     **
  258.     **    You call this function whenever you need the scrollbars to reflect the window
  259.     **    state and position.  If you change the sidebar sizes or indent sizes by hand,
  260.     **    you will need to call this.  Generally an application will not have to call this
  261.     **    directly, as there are functions for scrolling, setting sidebar sizes, indent
  262.     **    sizes, etc. */
  263.  
  264.  
  265.  
  266. void            GetContentOrigin(WindowPtr window, Point *contOrg);
  267.     /*
  268.     **    ¶ Return the origin of the content of the window.
  269.     **
  270.     **    INPUT:    window
  271.     **    OUTPUT:    contOrg
  272.     **
  273.     **    This function returns the origin of the content of the window.  The value
  274.     **    is gotten from the current value of the document scrollbars.  If a scrollbar
  275.     **    is missing, the control value for that scrollbar is assumed to be 0.  Note that
  276.     **    if you have sidebars in your document, the origin value has the sidebar value
  277.     **    subtracted.  For example:  You have a top sidebar of 32 pixels, and the vertical
  278.     **    scrollbar has a control value of 0.  This will return you a vertical origin
  279.     **    of -32.
  280.     **
  281.     **    __________
  282.     **
  283.     **    Also see:    SetContentOrigin. */
  284.  
  285.  
  286.  
  287. void            SetContentOrigin(WindowPtr window, long newh, long newv);
  288.     /*
  289.     **    ¶ Change the origin of the content of the window.
  290.     **
  291.     **    INPUT:    window
  292.     **            newh
  293.     **            newv
  294.     **
  295.     **    This function allows you to change the value of the document scrollbars, and by doing
  296.     **    this, the document is scrolled to reflect the change, and an update event is generated
  297.     **    for the document scroll.  Note that if you are using sidebars, you will have to subtract
  298.     **    the value of the sidebar to get the expected results.  Also note that this function
  299.     **    accepts long values.  You may have a proc for handling longs for the document scrollbars.
  300.     **    The proc is stored in the refCon of the document scrollbars.  If the refCon
  301.     **    value of the document scrollbars is 0, then it is assumed that values from 0
  302.     **    to 32767 are adequate for document scrolling.
  303.     **
  304.     **    __________
  305.     **
  306.     **    Also see:    GetContentOrigin. */
  307.  
  308.  
  309.  
  310. void            GetContentRect(WindowPtr window, Rect *contRct);
  311.     /*
  312.     **    ¶ Get bounding rect of the content area of the window.
  313.     **
  314.     **    INPUT:    window
  315.     **    OUTPUT:    contRct
  316.     **
  317.     **    This function returns a rectangle that represents the content area of the
  318.     **    window less the scrollbar and sidebar areas. */
  319.  
  320.  
  321.  
  322. void            SetDocSize(FileRecHndl frHndl, long hSize, long vSize);
  323.     /*
  324.     **    ¶ Set new document size and make approprate adjustments to the window.
  325.     **
  326.     **    INPUT:    frHndl
  327.     **            hSize
  328.     **            vSize
  329.     **
  330.     **    This function sets the document size to the new designated size.  It also
  331.     **    makes appropriate adjustments to the scrollbars to reflect the new size.
  332.     **    SetDocSize will not cause the window to scroll, even if you set the doc
  333.     **    size much smaller.  If the document shrinks such that the bottom of the
  334.     **    document is above the top of the window, it is not automatically scrolled
  335.     **    into place.  (This is the same behavior as system 7 finder.)  When the
  336.     **    user scrolls the document into view, the scrollbar range will be reduced
  337.     **    so that the user can’t scroll the document back out of view. */
  338.  
  339.  
  340.  
  341. void            SetSidebarSize(FileRecHndl frHndl, short newLeft, short newTop);
  342.     /*
  343.     **    ¶ Change the size of one or both sidebars.  Window is adjusted accordingly.
  344.     **
  345.     **    INPUT:    frHndl
  346.     **            newLeft
  347.     **            newTop
  348.     **
  349.     **    This function is used to set the size of the sidebars.  This is particularly
  350.     **    useful for being able to show and hide a tool palette, or if you are using
  351.     **    OCE and want to show a mailer at the top of your window.  The sidebar value
  352.     **    should initially be set in File.c, along with other document initialization.
  353.     **    If you wish to change only one of the two sidebar sizes, send in a value of
  354.     **    kwNoChange for the one that is not to change.
  355.     **
  356.     **    __________
  357.     **
  358.     **    Also see:    SetScrollIndentSize. */
  359.  
  360.  
  361.  
  362. void            SetScrollIndentSize(FileRecHndl frHndl, short newh, short newv);
  363.     /*
  364.     **    ¶ Change the size of the scroll indent area.  Window is adjusted accordingly.
  365.     **
  366.     **    INPUT:    frHndl
  367.     **            newh
  368.     **            newv
  369.     **
  370.     **    This function is used to set the size of the scrollbar indention.  The scrollbar
  371.     **    indentnion allows you to put status information or document display related
  372.     **    tool icons in line with the scrollbar.  They are considered part of the frame,
  373.     **    as document scrollbars, the grow icon, and sidebars are.  The scrollbar indent
  374.     **    value should initially be set in File.c, in the same fashion as sidebar values
  375.     **    are set.  If you wish to change only one of the two scrollbar indent, send in a
  376.     **    value of kwNoChange for the one that is not to change.
  377.     **
  378.     **    __________
  379.     **
  380.     **    Also see:    SetSidebarSize. */
  381.  
  382.  
  383.  
  384. FileRecHndl        GetNextDocument(WindowPtr window, OSType sftype);
  385.     /*
  386.     **    ¶ Iterator to walk window list and return the next document of correct type.
  387.     **
  388.     **    INPUT:    window
  389.     **            sftype
  390.     **    RESULT:    frHndl
  391.     **
  392.     **    This function returns the file reference for the next application window
  393.     **    of the designated kind.  If the window paramater is passed in as nil, it
  394.     **    finds the top-most window whose document type matches the requested OSType.
  395.     **    If the window parameter is passed in as non-nil, it returns the next window.
  396.     **    If there is no next window found, it returns nil.  The sftype parameter
  397.     **    restricts the finding of a window to a particular type.  If 0 is passed in
  398.     **    for sftype, then any application window will match.
  399.     **
  400.     **    __________
  401.     **
  402.     **    Also see:    GetNextWindow, GetPreviousWindow. */
  403.  
  404.  
  405.  
  406. WindowPtr        GetNextWindow(WindowPtr window, OSType sftype);
  407.     /*
  408.     **    ¶ Iterator to walk window list and return the next document window of correct type.
  409.     **
  410.     **    INPUT:    window
  411.     **            sftype
  412.     **
  413.     **    This function behaves the same as GetNextDocument, but returns a window pointer
  414.     **    instead of a file reference.
  415.     **
  416.     **    __________
  417.     **
  418.     **    Also see:    GetNextDocument, GetPreviousWindow. */
  419.  
  420.  
  421.  
  422. WindowPtr        GetPreviousWindow(WindowPtr window);
  423.     /*
  424.     **    ¶ Return the window in front of indicated window.
  425.     **
  426.     **    INPUT:    window
  427.     **
  428.     **    Returns the window in front of the window passed in.  If there is no window
  429.     **    in front, it returns -1, not nil.  -1 is typically used to indicate the front
  430.     **    of the window list, whereas nil is used to indicate the back.  This is done to
  431.     **    stay consistent with the expectations of the toolbox.
  432.     **
  433.     **    __________
  434.     **
  435.     **    Also see:    GetNextDocument, GetNextWindow, GetPreviousWindow. */
  436.  
  437.  
  438.  
  439. void            DoZoomWindow(WindowPtr window, EventRecord *event, short zoomDir);
  440.     /*
  441.     **    ¶ AppsToGo smart zoom.
  442.     **
  443.     **    INPUT:    window
  444.     **            event
  445.     **            zoomDir
  446.     **
  447.     **    This function handles zooming of the document window.  It zooms it to the
  448.     **    current monitor, up to the size of the document data. */
  449.  
  450.  
  451.  
  452. RgnHandle        DoCalcFrameRgn(WindowPtr window);
  453.     /*
  454.     **    ¶ Calculate region that encompasses entire window frame area.
  455.     **
  456.     **    INPUT:    window
  457.     **
  458.     **    This function calculates the region that encompasses the frame area of the
  459.     **    document.  The frame area consists of the document scrollbars, growIcon, sidebars,
  460.     **    and an optional application-defined frame area.  The region is generated in global
  461.     **    coordinates.  Since the frame region may encompass more than the
  462.     **    DTS.framework-supported scrollbars and growIcon, a procedure is first called to see
  463.     **    if there is anything additional in the frame region.  The field calcFrameRgnProc
  464.     **    holds the procedure pointer that contributes any extra to the frame region.  This
  465.     **    function is passed an empty region.  If there is no additional contribution to the
  466.     **    frame region, then the region should be left empty.  Once this procedure is
  467.     **    returned from, the remaining frame portion is added to this region.  The remaining
  468.     **    portion would consist of DTS.framework document scrollbars and a growIcon, if there
  469.     **    are any for this window.  The field calcFrameRgnProc is initialized to the
  470.     **    default value CalcFrameRgn.  If you wish an alternate drawFrameProc, then you
  471.     **    can replace the default in the function InitDocument, as the default is
  472.     **    already established at this point.
  473.     **
  474.     **    __________
  475.     **
  476.     **    Also see:    DoCalcContentRgn, DoCalcScrollRgn. */
  477.  
  478.  
  479.  
  480. RgnHandle        DoCalcScrollRgn(WindowPtr window);
  481.     /*
  482.     **    ¶ Calculate the region that encompasses the document scrollbars and growIcon.
  483.     **
  484.     **    INPUT:    window
  485.     **
  486.     **    This function calculates the region that encompasses the document scrollbars
  487.     **    and growIcon (if any).  The region is generated in global coordinates.
  488.     **
  489.     **    __________
  490.     **
  491.     **    Also see:    DoCalcFrameRgn, DoCalcContentRgn. */
  492.  
  493.  
  494.  
  495. void            DoContentClick(WindowPtr window, EventRecord *event, Boolean firstClick);
  496.     /*
  497.     **    ¶ Process a content click.  May call application to help.
  498.     **
  499.     **    INPUT:    window
  500.     **            event
  501.     **            firstClick
  502.     **
  503.     **    This function is called whenever the content portion of a window is clicked in.
  504.     **    It simply calls the procedure pointer stored in the field contentClickProc.
  505.     **    The field contentClickProc is initialized to ContentClick.  If you wish
  506.     **    an alternate contentClickProc, then you can replace the default in the function
  507.     **    InitDocument, as the default is already established at this point.  The
  508.     **    boolean firstClick is true if you chose this window to handle first clicks, and
  509.     **    if the click is actually a first click in the window.  A first click means that
  510.     **    the window content was clicked on, but the window was not the front window.  The
  511.     **    window has already been brought to the front, but you may wish the click to also
  512.     **    be handled as a content click.
  513.     **
  514.     **    Note that if you call DoContentClick directly, you need to handle the other
  515.     **    aspects of mouseDown events.  Generally you will simply want to call DoMouseDown
  516.     **    from your application.  If the mouseDown end up being in the content of a window,
  517.     **    DoMouseDown will call DoContentClick.
  518.     **
  519.     **    __________
  520.     **
  521.     **    Also see:    DoKeyDown, DoUpdate. */
  522.  
  523.  
  524.  
  525. void            DoDragWindow(WindowPtr window, EventRecord *event, Rect bounds);
  526.     /*
  527.     **    ¶ AppsToGo DragWindow code.  Use this instead of DragWindow.
  528.     **
  529.     **    INPUT:    window
  530.     **            event
  531.     **            bounds
  532.     **
  533.     **    This function is used to drag a window.  We can’t use the toolbox function
  534.     **    DragWindow, as the DTS.framework supports palettes.  Since we are supporting
  535.     **    palettes, we have to be able to drag a window that isn’t the front, and bring
  536.     **    it to the front of windows of its kind.  There is no way to coerce DragWindow
  537.     **    to do this. */
  538.  
  539.  
  540.  
  541. void            DoDrawFrame(WindowPtr window, Boolean activate);
  542.     /*
  543.     **    ¶ Draw the entire frame of a window.  Application may also be called for part.
  544.     **
  545.     **    INPUT:    window
  546.     **            activate
  547.     **
  548.     **    This function may be called when an update event occurs for the window.
  549.     **    If the update region intersects the frame region (calculated by DoCalcFrameRgn),
  550.     **    then a frame update occurs and this function is called.  It redraws the
  551.     **    document scrollbars and growIcon (if any) and then calls the procedure stored
  552.     **    in the field drawFrameProc, which has a default value of DrawFrame.  If you wish
  553.     **    an alternate drawFrameProc, then you can replace the default in the function
  554.     **    InitDocument, as the default is already established at this point. */
  555.  
  556.  
  557.  
  558. OSErr            DoFreeDocument(FileRecHndl frHndl);
  559.     /*
  560.     **    ¶ Opportunity to release a document’s additional memory.
  561.     **
  562.     **    INPUT:    frHndl
  563.     **    RESULT:    OSErr
  564.     **
  565.     **    This is called to generically call the document’s freeing procedure.  This document
  566.     **    is being disposed of, and any custom memory usage needs to be deallocated.  The
  567.     **    frHndl itself will be disposed of, but any handle references that it contains
  568.     **    need to be freed within the document’s freeing procedure.  The default freeing
  569.     **    procedure is called FreeDocument.
  570.     **
  571.     **    Note that DoFreeDocument is called by DisposeOneWindow.  This means that the
  572.     **    application will get a chance to dispose of any related memory due to a call to
  573.     **    DisposeOneWindow. */
  574.  
  575.  
  576.  
  577. OSErr            DoFreeWindow(FileRecHndl frHndl, WindowPtr window);
  578.     /*
  579.     **    ¶ Opportunity to release a window’s additional memory.
  580.     **
  581.     **    INPUT:    frHndl
  582.     **            window
  583.     **    RESULT:    OSErr
  584.     **
  585.     **    This is called to generically call the document’s window freeing procedure.
  586.     **    The window is going to be disposed of, and there may be related tasks to disposing
  587.     **    of the window.  A document may have related windows or views.  This is where you
  588.     **    would dispose of the related windows.  The default window freeing procedure is
  589.     **    called FreeWindow.
  590.     **
  591.     **    Note that DoFreeWindow is called by DisposeOneWindow.  This means that the
  592.     **    application will get a chance to dispose of any related memory due to a call to
  593.     **    DisposeOneWindow. */
  594.  
  595.  
  596.  
  597. OSErr            DoImageDocument(FileRecHndl frHndl);
  598.     /*
  599.     **    ¶ Application window’s imaging procedure (to either window or printer).
  600.     **
  601.     **    INPUT:    frHndl
  602.     **    RESULT:    OSErr
  603.     **
  604.     **    This function is called whenever the content portion of a window needs to be
  605.     **    updated or printed.  It simply calls the procedure pointer stored in the field
  606.     **    imageProc.  The field imageProc is initialized to ImageDocument.  If you wish
  607.     **    an alternate imageProc, then you can replace the default in the function
  608.     **    InitDocument, as the default is already established at this point.
  609.     **    Note that when the document’s imageProc is called, only the content can be
  610.     **    drawn to.  BeginContent is called prior to calling the imageProc, and
  611.     **    EndContent is called upon return. */
  612.  
  613.  
  614.  
  615. OSErr            DoInitContent(FileRecHndl frHndl, WindowPtr window);
  616.     /*
  617.     **    ¶ Application’s opportunity to initialize window content.
  618.     **
  619.     **    INPUT:    frHndl
  620.     **            window
  621.     **    RESULT:    OSErr
  622.     **
  623.     **    The window has been created, and is about to be displayed.  At this time, this
  624.     **    function is called.  It generically calls the window content initialization
  625.     **    procedure indicated within the frHndl.  The default window content initialization
  626.     **    procedure is called InitContent. */
  627.  
  628.  
  629.  
  630. Boolean            DoKeyDown(EventRecord *event);
  631.     /*
  632.     **    ¶ Process key event.  Framework may call application to finish event.
  633.     **
  634.     **    INPUT:    event
  635.     **
  636.     **    DoKeyDown is first called by the application.  If the key is a menu key, the
  637.     **    AppWannabe function DoMenuCommand is called.  If the key isn’t a menu
  638.     **    key, DoKeyDown starts walking through the window list, giving each window an
  639.     **    opportunity to handle the key.  Windows can handle it, eat it, or pass the key
  640.     **    through to the next window.
  641.     **    It gives each window a chance to handle the key by calling the key handling
  642.     **    procedure stored in the frHndl.  The default procedure is called KeyDown.  Here
  643.     **    are the rules for the window key handling procedure:
  644.     **
  645.     **    1)    If it handles the key, it returns true.  This completes the key handling.
  646.     **    2)    If it doesn’t handle the key, it returns false.  However, there are two
  647.     **        situations for not handling the key:
  648.     **            a) The window wants windows behind it to try handling the key.
  649.     **            b) The window wants nobody else to look at the key.
  650.     **       This is what the boolean passThrough is for.  If the procedure wishes the next
  651.     **       window to have a look at the key, it should set the boolean passThrough to true.
  652.     **       passThrough is already initialized to false prior to calling the procedure,
  653.     **       which is the common case, so the window key handling procedure only has to
  654.     **       worry about setting it true.
  655.     **
  656.     **    If the window never processes keys and always passes them through to the next
  657.     **    window, the contentKeyProc field in the frHndl should be set to nil.  This will
  658.     **    indicate to DoKeyDown that all keys should be passed through this window.
  659.     **    DTS.Draw has such a window.  The palette window doesn’t accept keys.  They are
  660.     **    passed through to document windows that are behind the palette. */
  661.  
  662.  
  663.  
  664. void            DoMouseDown(EventRecord *event);
  665.     /*
  666.     **    ¶ Process mouseDown event.  Framework may call application to finish event.
  667.     **
  668.     **    INPUT:    event
  669.     **
  670.     **    Call this whenever a mouse down event occurs in the application.  Everything is
  671.     **    handled.  Here’s what DoMouseDown may do, and what it depends on:
  672.     **    It handles:
  673.     **        inContent
  674.     **        inDrag
  675.     **        inGoAway
  676.     **        inGrow
  677.     **        inMenuBar
  678.     **        inSysWindow
  679.     **        inZoomIn
  680.     **        inZoomOut
  681.     **
  682.     **    inContent:
  683.     **        a)    If the window clicked on is a DA window, then bring the window to the front.
  684.     **        b)    If the window is the top-most and it is a document window, then
  685.     **            DoContentClick is called.
  686.     **        c)    If the window is not the top-most of its kind (palette,dialog,document),
  687.     **            then it is made the top-most of its kind.  If the window has the
  688.     **            kwDoFirstClick bit set, then DoContentClick is called, indicating to it
  689.     **            that this click is a first click (window-to-front click).
  690.     **
  691.     **    inDrag:
  692.     **        The window is dragged.  When released, if the command key was not held down at
  693.     **        the time of the click, the window is made the top-most window of its kind.
  694.     **
  695.     **    inGoAway:
  696.     **        The go-away is tracked.  If the document is dirty, then the user is asked if
  697.     **        the document should first be saved.  The user can save, discard, or cancel.
  698.     **        All cases are handled.
  699.     **
  700.     **    inGrow:
  701.     **        The window is grown.  Scrollbar adjustments are handled as they are in the
  702.     **        7.0 finder.
  703.     **
  704.     **    inMenuBar:
  705.     **        MenuSelect is called, then the AppWannabe function DoMenuCommand is called
  706.     **        with the result of MenuSelect.
  707.     **
  708.     **    inSysWindow:
  709.     **        SystemClick is called.
  710.     **
  711.     **    inZoomIn:
  712.     **    inZoomOut:
  713.     **        The window is grown, according to the human-interface guidelines for zooming.
  714.     **        The window is zoomed on the monitor that contains most of the window.  The zoom
  715.     **        size is limited by the document size.  All of these details are handled. */
  716.  
  717.  
  718.  
  719. short            MapMItem(short menuID, short menuItem);
  720.     /*
  721.     **    ¶ Convert hard menuItem ID to a soft ID.
  722.     **
  723.     **    INPUT:    menuID        The menu ID
  724.     **            menuItem    The menuItem, as returned by the Menu Manager (hard value)
  725.     **    RESULT:    short        The soft menu value.
  726.     **
  727.     **    This function converts a menu item hard-id (one returned by the toolbox) to a
  728.     **    soft-id (defined in the 'STR#' resource associated with the menu).  If there is
  729.     **    a 'STR#' resource defined with the same id as the menu, it is assumed to be
  730.     **    for the purpose of converting hard-id values to soft-id values.
  731.     **
  732.     **    __________
  733.     **
  734.     **    Also see:    UnmapMItem. */
  735.  
  736.  
  737.  
  738. short            UnmapMItem(short menuID, short menuItem);
  739.     /*
  740.     **    ¶ Convert soft menuITem ID to a hard ID.
  741.     **
  742.     **    INPUT:    menuID
  743.     **            menuItem
  744.     **    RESULT:    short
  745.     **
  746.     **    This function is the logical reverse of MapMItem. */
  747.  
  748.  
  749.  
  750. OSErr            DoReadDocument(FileRecHndl frHndl);
  751.     /*
  752.     **    ¶ Calls document’s read-document procedure, which reads the document.
  753.     **
  754.     **    INPUT:    frHndl
  755.     **    RESULT:    OSErr
  756.     **
  757.     **    DoReadDocument calls the specific read document procedure for the document.
  758.     **    The specific procedure is stored in the frHndl field readDocumentProc.  The
  759.     **    default value for readDocumentProc is ReadDocument.  It is the responsibility
  760.     **    of the readDocument procedure to call the readDocumentHeader procedure.  This is
  761.     **    done by calling DoReadDocumentHeader from within the readDocumentProc. */
  762.  
  763.  
  764.  
  765. OSErr            DoReadDocumentHeader(FileRecHndl frHndl);
  766.     /*
  767.     **    ¶ Calls document’s document read-header procedure, which reads the header.
  768.     **
  769.     **    INPUT:    frHndl
  770.     **    RESULT:    OSErr
  771.     **
  772.     **    DoReadDocumentHeader calls the specific read document header procedure for the
  773.     **    document.  The specific procedure is stored in the frHndl field
  774.     **    readDocumentHeaderProc.  The default value for readDocumentHeaderProc
  775.     **    is DefaultReadDocumentHeader. */
  776.  
  777.  
  778.  
  779. OSErr            DefaultReadDocumentHeader(FileRecHndl frHndl);
  780.     /*
  781.     **    ¶ Read the default document header format.
  782.     **
  783.     **    INPUT:    frHndl
  784.     **    RESULT:    OSErr
  785.     **
  786.     **    This function reads in the default header for a file.  The header information is
  787.     **    described by the structure DocHeaderInfo.  The typedef for this structure is in the
  788.     **    file DTS.Lib.h.  This block of header information is saved at the beginning of the
  789.     **    file.  It is written to the data fork.  If you want the header information saved in
  790.     **    the resource fork, you will have to have a custom readDocumentHeaderProc and
  791.     **    writeDocumentHeaderProc.  You can then simply read and write using the resource
  792.     **    fork, instead of the data fork, as the defaults do. */
  793.  
  794.  
  795.  
  796. OSErr            DoWriteDocument(FileRecHndl frHndl);
  797.     /*
  798.     **    ¶ Calls document’ write document procedure.
  799.     **
  800.     **    INPUT:    frHndl
  801.     **    RESULT:    OSErr
  802.     **
  803.     **    DoWriteDocument calls the specific write document procedure for the document.
  804.     **    The specific procedure is stored in the frHndl field writeDocumentProc.  The
  805.     **    default value for writeDocumentProc is WriteDocument.  It is the responsibility
  806.     **    of the writeDocument procedure to call the writeDocumentHeader procedure.  This is
  807.     **    done by calling DoWriteDocumentHeader from within the writeDocumentProc. */
  808.  
  809.  
  810.  
  811. OSErr            DoWriteDocumentHeader(FileRecHndl frHndl);
  812.     /*
  813.     **    ¶ Calls document’s write-header procedure.
  814.     **
  815.     **    INPUT:    frHndl
  816.     **    RESULT:    OSErr
  817.     **
  818.     **    DoWriteDocumentHeader calls the specific write document header procedure
  819.     **    for the document.  The specific procedure is stored in the frHndl field
  820.     **    writeDocumentHeaderProc.  The default value for writeDocumentHeaderProc
  821.     **    is DefaultWriteDocumentHeader. */
  822.  
  823.  
  824.  
  825. OSErr            DefaultWriteDocumentHeader(FileRecHndl frHndl);
  826.     /*
  827.     **    ¶ Writes the default header format.
  828.     **
  829.     **    INPUT:    frHndl
  830.     **    RESULT:    OSErr
  831.     **
  832.     **    This function writes out the default header for a file.  The header information is
  833.     **    described by the structure DocHeaderInfo.  The typedef for this structure is in the
  834.     **    file DTS.Lib.h.  This block of header information is saved at the beginning of the
  835.     **    file.  It is written to the data fork.  If you want the header information saved in
  836.     **    the resource fork, you will have to have a custom readDocumentHeaderProc and
  837.     **    writeDocumentHeaderProc.  You can then simply read and write using the resource
  838.     **    fork, instead of the data fork, as the defaults do. */
  839.  
  840.  
  841.  
  842. void            DoResizeContent(WindowPtr window, short oldh, short oldv);
  843.     /*
  844.     **    ¶ Called after a window is resized.  This is make related changes to the content.
  845.     **
  846.     **    INPUT:    window
  847.     **            oldh
  848.     **            oldv
  849.     **
  850.     **    This function is called when a window has been resized.  It is possible that window
  851.     **    contents have to be adjusted to match the new window size.  DoResizeContent
  852.     **    handles this.  DoResizeContent uses a procedure stored in the frHndl field
  853.     **    resizeContentProc.  If resizeContentProc is not nil, then the procedure is called.
  854.     **    The default value for resizeContentProc is ResizeContent. */
  855.  
  856.  
  857.  
  858. void            DoScrollFrame(WindowPtr window, long dx, long dy);
  859.     /*
  860.     **    ¶ Scroll a document’s frame area.
  861.     **
  862.     **    INPUT:    window
  863.     **            dx
  864.     **            dy
  865.     **
  866.     **    Some applications may need to scroll the "frame" of the document along with the
  867.     **    document contents.  This is common for applications with rulers, or other similar
  868.     **    sidebar items.  DoScrollFrame is called when document scrolling has occured.
  869.     **    DoScrollFrame uses a procedure stored in the frHndl field scrollFrameProc.
  870.     **    If scrollFrameProc is not nil, then the procedure is called.  The default value
  871.     **    for scrollFrameProc is ScrollFrame. */
  872.  
  873.  
  874.  
  875. void            DoUndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo);
  876.     /*
  877.     **    ¶ Part of the undo mechanism.  This dispatches to the document’s undo fixup.
  878.     **
  879.     **    INPUT:    frHndl
  880.     **            contOrg
  881.     **            afterUndo
  882.     **
  883.     **    This function is called by the hierarchical document package in response to an
  884.     **    undo/redo operation.  It is called prior to any undo information being applied
  885.     **    to the document so that you can prepare the document for an undo.  It is also
  886.     **    called after all undo tasks are performed on the document.  This last call is a
  887.     **    chance for any additional cleanup that might have to occur.  Commonly this second
  888.     **    call is used to reimage the document to show the document undone/redone.
  889.     **    DoUndoFixup doesn’t actually do the work, as it doesn’t know what kind of
  890.     **    document it was called for.  It simply looks in the frHndl at the field
  891.     **    undoFixupProc.  If undoFixupProc is not nil, then the procedure is called.
  892.     **    The default value for undoFixupProc is UndoFixup. */
  893.  
  894.  
  895.  
  896. void            CleanSendBehind(WindowPtr window, WindowPtr afterWindow);
  897.     /*
  898.     **    ¶ A better SendBehind, which is needed for floating palettes, etc.
  899.     **
  900.     **    INPUT:    window
  901.     **            afterUndo
  902.     **
  903.     **    This function is exactly what it would seem by the name.  SendBehind has some
  904.     **    problems in that it causes too much repainting of windows.  This function allows
  905.     **    you to change the layer of a window very cleanly.  It also calls HiliteWindows,
  906.     **    which walks the window list and adjusts window hilighting for the various types
  907.     **    of windows.  The top-most of a type is hilited, and all other windows of that
  908.     **    type are unhilited. */
  909.  
  910.  
  911.  
  912. void            CleanSendInFront(WindowPtr window, WindowPtr beforeWindow);
  913.     /*
  914.     **    ¶ Bring a window in front of another, while handling floating palettes, etc.
  915.     **
  916.     **    INPUT:    window
  917.     **            beforeWindow
  918.     **
  919.     **    Again, this is exactly what it would seem.  See CleanSendBehind for
  920.     **    more information. */
  921.  
  922.  
  923.  
  924. void            HiliteWindows(void);
  925.     /*
  926.     **    ¶ Makes sure that the hiliting of windows is correct.
  927.     **
  928.     **    This function is called to adjust the hilites of all windows.  Since DTS.framework
  929.     **    supports palettes, there is possibly more than one hilited window.  The window
  930.     **    manager doesn’t want to play this game, so certain additional functions had to be
  931.     **    written.  Basically, if you are using palettes, don’t make any window manager calls
  932.     **    that change window hiliting.  Use CleanSendBehind and CleanSendInFront.  These
  933.     **    take care of window shuffling correctly.  Of course, there are calls you can’t
  934.     **    avoid, such as closing a window.  If you do these operations directly, call
  935.     **    HiliteWindows afterwards. */
  936.  
  937.  
  938.  
  939. void            UnhiliteWindows(void);
  940.     /*
  941.     **    ¶ Unhilite all windows.  This is done before bringing up a modal dialog, for example.
  942.     **
  943.     **    This is called to unhilite all windows.  DTS.framework allows for multiple hilited
  944.     **    windows.  All of them have to be unhilited prior to bringing up a modal dialog or
  945.     **    alert.  Call this to unhilite all windows, do the modal dialog or alert, and then
  946.     **    call HiliteWindows to set the hiliting back to normal. */
  947.  
  948.  
  949.  
  950. void            DoUpdate(WindowPtr window);
  951.     /*
  952.     **    ¶ Update the window.  Do this in response to an update event.
  953.     **
  954.     **    INPUT:    window
  955.     **
  956.     **    This is called when an update event is received for a window.  First, the
  957.     **    updateRgn is separated into two parts.  Part 1 holds the window frame area,
  958.     **    if any.  This is the area that might hold the scrollbars, grow icon, and
  959.     **    any other application-specific frame parts.  This is drawn first.  Once
  960.     **    this is done, the remainder of the updateRgn is drawn.  This allows us to
  961.     **    handle all of the frame clipping without using the clipRgn.  By freeing up
  962.     **    the clipRgn, we allow the application to use it without having to share. */
  963.  
  964.  
  965.  
  966. void            DoSetCursor(Cursor *cursor);
  967.     /*
  968.     **    ¶ Main application cursor-setting procedure.
  969.     **
  970.     **    INPUT:    cursor
  971.     **
  972.     **    Call this function to correctly set the cursor and to inform DTS.framework that
  973.     **    you have specifically set the cursor.  This is used when you temporarily want to
  974.     **    set the cursor, such as just before a slow operation.  For a slow operation, you
  975.     **    may want to put up the wait cursor.  Use DoSetCursor for this, and then when the
  976.     **    operation is over and program control returns to the main event loop, the cursor
  977.     **    will be recalculated to the current cursor for the mouse position. */
  978.  
  979.  
  980.  
  981. CursPtr            DoSetResCursor(short crsrID);
  982.     /*
  983.     **    ¶ Given an ID, instead of a pointer, set the cursor.
  984.     **
  985.     **    INPUT:    crsrID
  986.     **    RESULT:    CursPtr
  987.     **
  988.     **    This function serves the same purpose as DoSetCursor, except that you pass in
  989.     **    a resID, instead of a cursor pointer.  The resource is loaded, the cursor is then
  990.     **    copied into permanent memory, and then DoSetCursor is called with a pointer to
  991.     **    the cursor image. */
  992.  
  993.  
  994.  
  995. void            DoWindowCursor(void);
  996.     /*
  997.     **    ¶ Iterates through the windows, giving the document a chance to set the cursor.
  998.     **
  999.     **    Call this function to calculate what the cursor should be for various windows.
  1000.     **    The result of this function is to set the cursor based on the current mouse
  1001.     **    position.  In addition to setting the cursor, the cursor region is calculated.
  1002.     **    The cursor region is kept in the global variable gCursorRgn.
  1003.     **    This function walks the window list, and for each document window, it calls the
  1004.     **    window’s cursor handling procedure.  The cursor handling procedure is stored in
  1005.     **    the frHndl field windowCursorProc.
  1006.     **    Here are the rules for cursor and gCursorRgn determination:
  1007.     **
  1008.     **    1)    See if the mouse position is currently inside the gCursorRgn.  If so, leave.
  1009.     **    2)    Since the mouse position is outside the current gCursorRgn, we need to
  1010.     **        recalculate the cursor.  Set the gCursorRgn to wide-open.  From now on, we
  1011.     **        will eliminate areas from gCursorRgn that don’t apply to the new mouse
  1012.     **        location and new cursor.
  1013.     **    3)    For each visible window (starting with the front window):
  1014.     **        a)    If the windowCursorProc is nil and the mouse position is over the structure
  1015.     **            region of the window, set the cursor to an arrow and intersect the gCursorRgn
  1016.     **            with the structure region of the window.  This limits the cursor to the area
  1017.     **            of the window that is visible.
  1018.     **        b)    If the windowCursorProc is nil and the mouse position is outside the
  1019.     **            structure region of the window, diff out the structure region from
  1020.     **            gCursorRgn and proceed to the next visible window in the window list.
  1021.     **        c)    If the windowCursorProc is not nil, call the procedure.  Note that the
  1022.     **            procedure is called whether or not the mouse location is over the window.
  1023.     **            This is to allow the procedure to determine if it should be the last
  1024.     **            window checked.
  1025.     **            The proc’s job is as follows:
  1026.     **            1)    If the cursor is over a position that is determined by the window, then
  1027.     **                the proc removes other areas from gCursorRgn.  Note that it should not
  1028.     **                simply set the area to what it "thinks" is the correct area.  This window
  1029.     **                may not be the front-most.  Other windows will have already been
  1030.     **                subtracted from gCursorRgn.  The resultant gCursorRgn is the correct
  1031.     **                cursor area, and should be passed to WaitNextEvent calls in the
  1032.     **                application.  Also, the cursor should be set to the correct cursor, of
  1033.     **                course.  You should also return true, as the cursor has been determined.
  1034.     **                The rule of thumb for what you should do to the gCursorRgn is that you
  1035.     **                should calculate the cursor region as if the window was the top window.
  1036.     **                Once this is done, intersect the gCursorRgn with this region.  The result
  1037.     **                should be stored in gCursorRgn.
  1038.     **                Since you determined a cursor and gCursorRgn in this case, you should
  1039.     **                return true.  Returning true indicates to DoWindowCursor that the
  1040.     **                cursor has been determined, and that it should stop processing windows.
  1041.     **            2)    If the cursor is not over a position for this window, then you should
  1042.     **                return.  You will either pass back true or false.  If you don’t wish
  1043.     **                windows behind this window to have a shot at cursor determination, then
  1044.     **                return true.  This states that the cursor is "determined".  It is, in the
  1045.     **                sense that no further determination will occur.  If you return false, then
  1046.     **                other windows get a shot at determining the cursor.  If there are no other
  1047.     **                windows, then the cursor is set to an arrow, and gCursorRgn is set to the
  1048.     **                area that is outside all windows for the application.
  1049.     **                (Common case:)  If you don’t want windows behind this one to determine
  1050.     **                the cursor:
  1051.     **                a)    Set the cursor to an arrow.  Since you are outside this window, the
  1052.     **                    cursor should be an arrow.  The cursor may be over the desktop or
  1053.     **                    menubar, or some other window that isn’t the top-most window.  All of
  1054.     **                    these cases should have an arrow cursor.  Also, you need to diff out
  1055.     **                    the window’s structure region from gCursorRgn.  By diffing it out,
  1056.     **                    you will get mouse-moved events when the cursor is moved back over
  1057.     **                    this window.
  1058.     **                b)    Return true.  This tells DoWindowCursor that the cursor has
  1059.     **                    been determined.
  1060.     **                (Uncommon case:)  If you want windows behind this one to possibly
  1061.     **                    determine the cursor:  Return false.  That’s it.  DTS.framework will
  1062.     **                    automatically remove the structure region for this window from
  1063.     **                    gCursorRgn if you return false.  If you return false, DTS.framework
  1064.     **                    proceeds to the next window, if there is one.  If there are no more
  1065.     **                    windows behind this one, then DTS.framework sets the cursor to an
  1066.     **                    arrow, and the resultant gCursorRgn will have all of the structure
  1067.     **                    regions for the windows removed from it. */
  1068.  
  1069.  
  1070.  
  1071. WindowPtr        FrontWindowOfType(long wkind, Boolean firstVis);
  1072.     /*
  1073.     **    ¶ Get front-most window meeting criteria.
  1074.     **
  1075.     **    INPUT:    wkind
  1076.     **            firstVis
  1077.     **    RESULT:    WindowPtr
  1078.     **
  1079.     **    Since DTS.framework supports three distinct categories of windows
  1080.     **    (document/palette/dialog), it is often necessary to get the front-most
  1081.     **    window of a certain type.  Use this function to accomplish this.  Basically,
  1082.     **    this takes the place of FrontWindow if you have more than one category of
  1083.     **    window in your application. */
  1084.  
  1085.  
  1086.  
  1087. short            HCenteredAlert(short alertID, WindowPtr relatedWindow, ModalFilterUPP filter);
  1088.     /*
  1089.     **    ¶ Put up an alert, and also make sure that hiliting of other windows is correct.
  1090.     **
  1091.     **    INPUT:    alertID
  1092.     **            relatedWindow
  1093.     **            filter
  1094.     **    RESULT:    short
  1095.     **
  1096.     **    This function gets an alert, and handles hiliting of windows correctly.
  1097.     **    The reason for this function is that there may be more than one hilited
  1098.     **    window due to the possibility of floating palettes.  The calls to UnhiliteWindows
  1099.     **    and HiliteWindows make sure that while the alert is up, there are no other
  1100.     **    hilited windows. */
  1101.  
  1102.  
  1103.  
  1104. OSErr            GetWindowFormats(void);
  1105.     /*
  1106.     **    ¶ Read in and unflatten resource 'WFMT' #128.
  1107.     **
  1108.     **    RESULT:    OSErr
  1109.     **
  1110.     **    This function gets the application window formats that were created with
  1111.     **    the AppsToGo application editor.  The window formats are stored in the resource
  1112.     **    'WFMT' id #128.  They are first read in, and then they are unflattened
  1113.     **    by calling HReadWindowFormats. */
  1114.  
  1115.  
  1116.  
  1117. OSErr            HReadWindowFormats(Handle wfmt);
  1118.     /*
  1119.     **    ¶ Unflattens a window-format handle into separate hierarchical document objects.
  1120.     **
  1121.     **    INPUT:    wfmt
  1122.     **    RESULT:    OSErr
  1123.     **
  1124.     **    This function is called to unflatten a window-format handle into separate
  1125.     **    hierarchical document objects.  The assumption is that there is only one
  1126.     **    of these multiple window definitions, and therefore if there is already
  1127.     **    one in the global gWindowFormats, it is disposed of.  This is exactly the
  1128.     **    behavior needed by the AppsToGo application editor. */
  1129.  
  1130.  
  1131.  
  1132. OSErr            GetSeparateWFMT(OSType sftype, short *numAdded);
  1133.     /*
  1134.     **    ¶ Add (or remove) window-format resource definition to global gWindowFormats.
  1135.     **
  1136.     **    INPUT:    sftype
  1137.     **    OUTPUT:    numAdded
  1138.     **    RESULT:    OSErr
  1139.     **
  1140.     **    This function is called to add (or remove) a window-format resource definition
  1141.     **    to the global gWindowFormats.  The purpose of this is to be able to break up the
  1142.     **    single 'WFMT' id #128 resource, which may get quite large for some applications.
  1143.     **    NewDocumentWindow and AddControlSet automatically call GetSeparateWFMT 
  1144.     **    for you.  If the document definition is in a separate 'WFMT' resource,
  1145.     **    then that definition is added to gWindowFormats long enough to be used, and then
  1146.     **    it is removed.  The 'WFMT' resource can be of any id other than 128, and must be
  1147.     **    named with the DocType, such as ABOT for the about box.  (The name must always be
  1148.     **    4 characters.)  Passing in 0 for the DocType (OSType) disposes of however many
  1149.     **    were added.  The number added is returned from the first time it is called. */
  1150.  
  1151.  
  1152.  
  1153. OSErr            AddControlSet(WindowPtr window, OSType sftype, short visMode,
  1154.                               short xoffset, short yoffset, CObjCtlHndl cco);
  1155.     /*
  1156.     **    ¶ Add a set of controls (and sets referenced by that set) to the window.
  1157.     **
  1158.     **    INPUT:    window
  1159.     **            sftype
  1160.     **            visMode
  1161.     **            xoffset
  1162.     **            yoffset
  1163.     **    IN/OUT    cco
  1164.     **    RESULT:    OSErr
  1165.     **
  1166.     **    This function adds a set of controls (and sets referenced by that set) to the
  1167.     **    window.  The control sets are created with the AppsToGo application editor. */
  1168.  
  1169.  
  1170.  
  1171. ControlHandle    MakeControl(WindowPtr window, TreeObjHndl cobj,
  1172.                             short visMode, short xoffset, short yoffset);
  1173.     /*
  1174.     **    ¶ Create a control based on the control definition object.
  1175.     **
  1176.     **    INPUT:    window
  1177.     **            cobj
  1178.     **            visMode
  1179.     **            xoffset
  1180.     **            yoffset
  1181.     **    RESULT:    ControlHandle
  1182.     **
  1183.     **    This function is used to create a control based on the control definition object.
  1184.     **    The control definition objects are created with the AppsToGo application editor. */
  1185.  
  1186.  
  1187.  
  1188. CObjCtlHndl        GetControlSet(WindowPtr window, OSType sftype, ControlHandle *retDataCtl);
  1189.     /*
  1190.     **    ¶ Return Data control that has reference to all controls in control set.
  1191.     **
  1192.     **    INPUT:    window
  1193.     **            sftype
  1194.     **    OUTPUT:    retDataCtl
  1195.     **    RESULT:    CObjCtlHndl
  1196.     **
  1197.     **    This function is called to return the handle of the Data control that has
  1198.     **    a reference to all of the controls in the control set.  Once you get the
  1199.     **    Data control, you can then look at the data in the control to get the handle
  1200.     **    of the controls within the control set. */
  1201.  
  1202.  
  1203.  
  1204. void            DisplayControlSet(WindowPtr window, OSType sftype, short visMode);
  1205.     /*
  1206.     **    ¶ Show or hide a set of controls.
  1207.     **
  1208.     **    INPUT:    window
  1209.     **            sftype
  1210.     **            visMode
  1211.     **
  1212.     **    This function is used to show or hide a set of controls. */
  1213.  
  1214.  
  1215.  
  1216. void            DrawControlSet(WindowPtr window, OSType sftype);
  1217.     /*
  1218.     **    ¶ Draw a set of controls.
  1219.     **
  1220.     **    INPUT:    window
  1221.     **            sftype
  1222.     **
  1223.     **    This function is used to draw a set of controls. */
  1224.  
  1225.  
  1226.  
  1227. void            DisposeControlSet(WindowPtr window, OSType sftype);
  1228.     /*
  1229.     **    ¶ Dispose a set of controls.
  1230.     **
  1231.     **    INPUT:    window
  1232.     **            sftype
  1233.     **
  1234.     **    This function is used to dispose a set of controls. */
  1235.  
  1236.  
  1237.  
  1238. void            DisposeControlFromSet(ControlHandle ctl, OSType sftype);
  1239.     /*
  1240.     **    ¶ Dispose a single control from a control set.
  1241.     **
  1242.     **    INPUT:    window
  1243.     **            sftype
  1244.     **
  1245.     **    This function is used to dispose a single control from a control set.  If it
  1246.     **    is the last control in the set, the dataCtl which contains the set
  1247.     **    information is also disposed of. */
  1248.  
  1249.  
  1250.  
  1251. Boolean            DoAdjustMBARMenus(WindowPtr window, short menuBarID);
  1252.     /*
  1253.     **    ¶ Adjust all of the menus in the designated MBAR.
  1254.     **
  1255.     **    INPUT:    window
  1256.     **            menuBarID
  1257.     **    RESULT:    Boolean
  1258.     **
  1259.     **    This fuction is called to adjust all of the menus in the designated MBAR. 
  1260.     **    The functions gets each menu handle, and then disables all of the menu items
  1261.     **    for that menu.  It then calls the application to give the application the
  1262.     **    chance to enable the appropriate menu items.
  1263.     **
  1264.     **    __________
  1265.     **
  1266.     **    Also see:    DoAdjustMenus
  1267.     **                    AppWannabe function where the menu handling chain
  1268.     **                    begins.  The application can do whatever it wants
  1269.     **                    to adjust the menus, but the easiest thing is to
  1270.     **                    just call DoAdjustMBARMenus.
  1271.     **
  1272.     **                AdjustMenuItems
  1273.     **                    AppWannabe function that DoAdjustMBARMenus calls
  1274.     **                    for each menu.  If the top window is not a document
  1275.     **                    window, or if there is no window, then AdjustMenuItems
  1276.     **                    is called directly.  If the top window is a document
  1277.     **                    window, then the document procPtr adjustMenuItemsProc
  1278.     **                    is called.  Note that adjustMenuItemsProc is initialized
  1279.     **                    to AdjustMenuItems.  This means that, unless you change
  1280.     **                    it, AdjustMenuItems is called in all cases. */
  1281.  
  1282.  
  1283.  
  1284. OSErr            OpenRuntimeOnlyAutoNewWindows(void);
  1285.     /*
  1286.     **    ¶ Open all windows that are correctly designated with AppsToGo application editor.
  1287.     **
  1288.     **    RESULT:    OSErr
  1289.     **
  1290.     **    This function is used to open all of the windows that are correctly designated
  1291.     **    with the AppsToGo application editor.  You should call this in your application
  1292.     **    at startup time if your application is editable with the AppsToGo
  1293.     **    application editor. */
  1294.  
  1295.  
  1296.  
  1297. OSErr            NewDocumentWindow(FileRecHndl *frHndl, OSType sftype, Boolean incTitleNum);
  1298.     /*
  1299.     **    ¶ Calls NewDocument, and if successful, DoNewWindow.
  1300.     **
  1301.     **    INPUT:    sftype
  1302.     **            incTitleNum
  1303.     **    OUTPUT:    frHndl
  1304.     **    RESULT:    OSErr
  1305.     **
  1306.     **    This call can be done as two separate calls (NewDocument / DoNewWindow).  However,
  1307.     **    this function both creates the document, and then gives the document a window.
  1308.     **    It also handles errors and puts up an error window if something goes wrong. */
  1309.  
  1310.  
  1311.  
  1312. OSErr            OpenDocumentWindow(FileRecHndl *frHndl, FSSpecPtr fileToOpen, char permission);
  1313.     /*
  1314.     **    ¶ Calls OpenDocument, and if successful, DoNewWindow.
  1315.     **
  1316.     **    INPUT:    fileToOpen
  1317.     **            permission
  1318.     **    OUTPUT:    frHndl
  1319.     **    RESULT:    OSErr
  1320.     **
  1321.     **    This call can be done as two separate calls (OpenDocument / DoNewWindow).  However,
  1322.     **    this function both creates the document, and then gives the document a window.
  1323.     **    It also handles errors and puts up an error window if something goes wrong. */
  1324.  
  1325.  
  1326.  
  1327. #endif
  1328.